package com.example.mvpdemo.login;

import com.example.mvpdemo.base.BasePresenter;

public class LoginPresenter extends BasePresenter<LoginActivity, LoginModel, Ilogin.VP> {

    @Override
    public LoginModel getmModelInstance() {
        return new LoginModel(this);
    }

    @Override
    public Ilogin.VP getContract() {
        return new Ilogin.VP() {
            @Override
            public void requestLogin(String name, String pwd)  {
                try {
                    mModel.getContract().requestLogin(name, pwd);
                } catch (Exception e) {
                    e.printStackTrace();
                    //处理异常
                }
            }

            @Override
            public void requestLoginResult(boolean loginStatusResult) {
                mView.getContract().requestLoginResult(loginStatusResult);
            }
        };
    }

//    @Override
//    public void requestLogin(String name, String pwd) throws Exception {
//        if (name != null || pwd != null) {
//            mModel.requestLogin(name, pwd);
//        }
//    }
//
//    @Override
//    public void requestLoginResult(boolean loginStatusResult) {
//        mView.requestLoginResult(true);
//    }
}
